import Vue from "vue";
import VueRouter from "vue-router";
import adminRoutes from "@/router/adminRouter";
import userRoutes from "@/router/userRouter";
import userLogin from "@/components/user/userLogin";
import notFound from "@/components/notFound/notFound";
import test from "@/components/test";
import aliTest from "@/components/aliTest";

Vue.use(VueRouter);

const baserRoutes = [
    {
        path: '/',
        redirect: '/userLogin'
    },
    {
        path: '/userLogin',
        component: userLogin
    },

    {
        path: '/test',
        component: test
    },
    {
        path: '/aliTest',
        component: aliTest
    },
    {
        path: '*',
        component: notFound
    }
    ];

const routes = baserRoutes.concat(adminRoutes, userRoutes);

//取出重复路由跳转的警告
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
    routes,
    mode: 'history',
    scrollBehavior() {
        return {x: 0, y: 0};
    }
});

Vue.prototype.$myRouter = router;
export default router;
